home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4457 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: lrz-muenchen.de!news
  2. From: Gloger@lrz.uni-muenchen.de (Wolfram Gloger)
  3. Newsgroups: comp.sys.sgi.misc,comp.lang.c,comp.unix.programmer
  4. Subject: Re: memory management in UNIX (SGI IRIX)
  5. Date: 2 Feb 1996 13:02:03 GMT
  6. Organization: Universitaet Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4et20b$q6i@sparcserver.lrz-muenchen.de>
  9. References: <DM0Jv9.9F4@bii.bruker.com>
  10. Reply-To: Gloger@lrz.uni-muenchen.de
  11. NNTP-Posting-Host: sun6.lrz-muenchen.de
  12.  
  13. jem@bii.bruker.com (Joe Meier) writes:
  14.  
  15. >   We have a problem with a program running under UNIX (SGI IRIX 5.x).  
  16. >It uses X11 for a graphical user interface.  
  17. >The program allocates and frees large amounts of memory for data 
  18. >(sometimes chunks as big as 20M).  The problem is that in a relatively
  19. >short time the system runs out of swap sapce and we have to kill the program.
  20. >We have investigated the problem and it seems to be that the allocated memory
  21. >is getting segmented, so that even though the memory is freed by calls to
  22. >"free", the next malloc does not necessairly use the freed space because it
  23. >cannot find a large enough contiguous block and instead allocates more from
  24. >the system.  When we were working with smaller data sizes this was not a 
  25. >problem, but the bigger data sizes is causing some svere problems.  The 
  26. >first question is whether anyone else has encountered similar problems
  27. >and what caused them and how they solved it?
  28.  
  29. The cause is most probably heap fragmentation.  Conventional malloc()/free()
  30. implementations can only release contiguous regions of memory at the top of
  31. the heap, not anything in the middle.
  32.  
  33. You might want to check out the `Free memory:  Why isn't it doing anything ?'
  34. thread on comp.sys.sgi.misc.  In short, try:
  35.  
  36. ftp://g.oswego.edu:pub/misc/malloc-2.6.2.c
  37.  
  38. and see if it makes a difference.  This implementation uses mmap() on
  39. large chunks, which can be returned to the system immediately on a
  40. call to free().
  41.  
  42. Regards,
  43. Wolfram.
  44.